package doudizhu2;

import java.util.*;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-04-05
 * Time: 15:15
 */
public class PokerGame {

    static HashMap<Integer,String> hm = new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();

    static {
        String[] color = {"◆","♣","♥","♠"};
        String[] number = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};

        int serialNumber = 1;
        for (String n:number) {
            for (String c:color) {
                hm.put(serialNumber,c + n);
                list.add(serialNumber);
                serialNumber++;
            }
        }

        hm.put(serialNumber,"小王");
        list.add(serialNumber);
        serialNumber++;
        hm.put(serialNumber,"大王");
        list.add(serialNumber);

        System.out.println(list);

    }

    public PokerGame() {

        Collections.shuffle(list);
        TreeSet<Integer> lord = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();

        for (int i = 0; i < list.size(); i++) {
            if (i <= 2) {
                lord.add(list.get(i));
                continue;
            }
            if (i % 3 == 0) {
                player1.add(list.get(i));
            }
            if (i % 3 == 1) {
                player2.add(list.get(i));
            }
            if (i % 3 == 2) {
                player3.add(list.get(i));
            }
        }

        lookPoker("底牌",lord);
        lookPoker("胡歌",player1);
        lookPoker("富大龙",player2);
        lookPoker("吴彦祖",player3);


    }

    public static void lookPoker(String name,TreeSet<Integer> ts){
        System.out.print(name + ": ");
        for (int serialNumber : ts) {
            String poker = hm.get(serialNumber);
            System.out.print(poker + " ");
        }
        System.out.println();
    }

}
